const router = require('koa-router')()
const { exec } = require('../db')

// router.prefix('/api')

router.get('/api/users', async (ctx, next) => {
	const usersData = await exec(`select username, id from users`)
	ctx.body = {
		code: 0,
		msg: 'success',
		data: usersData
	}
})

router.get('/', function (ctx, next) {
	ctx.body = 'this is a users response!'
})

router.get('/bar', function (ctx, next) {
	ctx.body = 'this is a users/bar response'
})

module.exports = router
